<!-- 预览组件 -->
<template>
    <my-dialog title="预览" :isShow="props.isShow" @close="close">
        <json-form :data="props.data" :formData="formData" @valueChange="valueChange"></json-form>
    </my-dialog>
</template>
    
<script setup>
    import {ref,watch} from 'vue'
    const props = defineProps(['isShow','data'])
    const emits = defineEmits(['close'])
    /* 用data中唯一属性当做formData中的key */
    const formData = ref({})
    const formOptions = ref([])
    watch(()=>props.data,newValue=>{
        if(!newValue.length) return
        console.log(newValue);
        newValue.forEach(item => {
            formData.value[item.id] = ''
        });
    },{deep:true})
    const valueChange = (key,value)=>{
        formData.value[key] = value
    }
    const close = ()=>{
        emits('close')
    }
</script>
    
<style scoped>
    
</style>
